

using System;
using System.Collections.Generic;
using System.Text;

using SubSonic;

namespace JTC.MiniCommerce.Store {
  public partial class ReviewController {
  
    #region Methods
    
    #region Public

    /// <summary>
    /// Fetch by product id.
    /// </summary>
    /// <param name="productId">The product id.</param>
    /// <returns></returns>
    public ReviewCollection FetchByProductId(int productId) {
      ReviewCollection reviewCollection = new ReviewCollection().
        Where(Review.Columns.ProductId, Comparison.Equals, productId).
        Load();
      return reviewCollection;
    }

    /// <summary>
    /// Fetch by product id and is approved.
    /// </summary>
    /// <param name="productId">The product id.</param>
    /// <returns></returns>
    public ReviewCollection FetchByProductIdAndIsApproved(int productId) {
      ReviewCollection reviewCollection = new ReviewCollection().
        Where(Review.Columns.ProductId, Comparison.Equals, productId).
        Where(Review.Columns.IsApproved, Comparison.Equals, true).
        Load();
      return reviewCollection;
    }
    
    #endregion
    
    #endregion
    
  }
}
